/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package menu;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author abosancic
 */
@Entity
@Table(name = "mjesto")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Mjesto.findAll", query = "SELECT m FROM Mjesto m"),
    @NamedQuery(name = "Mjesto.findById", query = "SELECT m FROM Mjesto m WHERE m.id = :id"),
    @NamedQuery(name = "Mjesto.findByNaziv", query = "SELECT m FROM Mjesto m WHERE m.naziv = :naziv"),
    @NamedQuery(name = "Mjesto.findByOpis", query = "SELECT m FROM Mjesto m WHERE m.opis = :opis")})
public class Mjesto implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Size(max = 255)
    @Column(name = "naziv")
    private String naziv;
    @Size(max = 255)
    @Column(name = "opis")
    private String opis;
    @OneToMany(mappedBy = "idmjesta")
    private Collection<Adresa> adresaCollection;
    @JoinColumn(name = "iddrzave", referencedColumnName = "iddrzave")
    @ManyToOne
    private Drzava iddrzave;

    public Mjesto() {
    }

    public Mjesto(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNaziv() {
        return naziv;
    }

    public void setNaziv(String naziv) {
        this.naziv = naziv;
    }

    public String getOpis() {
        return opis;
    }

    public void setOpis(String opis) {
        this.opis = opis;
    }

    @XmlTransient
    public Collection<Adresa> getAdresaCollection() {
        return adresaCollection;
    }

    public void setAdresaCollection(Collection<Adresa> adresaCollection) {
        this.adresaCollection = adresaCollection;
    }

    public Drzava getIddrzave() {
        return iddrzave;
    }

    public void setIddrzave(Drzava iddrzave) {
        this.iddrzave = iddrzave;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Mjesto)) {
            return false;
        }
        Mjesto other = (Mjesto) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "menu.Mjesto[ id=" + id + " ]";
    }
    
}
